package com.t.codebook.service.impl;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.t.codebook.mapper.CodeBankMapper;
import com.t.codebook.model.dto.codeBank.CodeBankQueryRequest;
import com.t.codebook.model.entity.CodeBank;
import com.t.codebook.model.vo.CodeBankVO;
import com.t.codebook.service.CodeBankService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.List;

/**
* 代码库服务实现
*
*/
@Service
@Slf4j
public class CodeBankServiceImpl extends ServiceImpl<CodeBankMapper, CodeBank> implements CodeBankService {


    @Resource
    private CodeBankMapper codeBankMapper;


    /**
    * 根据ID获取代码库
    *
    * @return
    */
    @Override
    public CodeBankVO getCodeBankVO(Long id) {
        CodeBankVO codeBankVo = codeBankMapper.selectCodeBankById(id);
        return codeBankVo;
    }

    /**
    * 分页获取代码库封装
    *
    * @return
    */
    @Override
    public PageInfo<CodeBankVO> getCodeVOPage(CodeBankQueryRequest codeBankQueryRequest) {
        PageHelper.startPage(codeBankQueryRequest.getCurrent(), codeBankQueryRequest.getPageSize());
        List<CodeBankVO> codeBankVOS = codeBankMapper.selectCodeBankListByCondition(codeBankQueryRequest);
        return new PageInfo<CodeBankVO>(codeBankVOS);
    }


}